/*
*	ID : pallab81
* 	PROG : 4857
* 	LANG : C++
* 	2011-10-06-10.35.52 Thursday
*
* 	"I have not failed, I have just found 10000 ways that won't work.
*/
#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
#include <fstream>
#include <string>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <iomanip>

#include <ctime>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <climits>
#include <cstring>
#include <cstdlib>

using namespace std;

#define VI vector< int >
#define CI( x ) scanf("%d",&x)
#define CL( x ) scanf("%lld",&x)
#define CD( x ) scanf("%lf",&x )
#define foR(i,st,ed) for(int i = st ; i < ed ; ++i )
#define fo(i,ed) foR( i , 0 , ed )
#define foE(i,st,ed) for(int i = st ; i <= ed ; ++i )
#define foit(i, x) for (typeof((x).begin()) i = (x).begin(); i != (x).end(); i++)
#define bip system("pause")
#define Int long long
#define pb push_back
#define SZ(X) (int)(X).size()
#define LN(X) (int)(X).length()
#define mk make_pair
#define f first
#define s second
#define SET( ARRAY , VALUE ) memset( ARRAY , VALUE , sizeof(ARRAY) )

inline void wait(double seconds) {
    double endtime = clock()+(seconds * CLOCKS_PER_SEC);
    while (clock() < endtime) {
        ;
    }
}

int kase=1;
int N,color;
VI vi;
int dp[101][101];

inline void Read(){
    CI(N);
    CI(color);
    vi.clear();
    fo(i,N){
        int x;CI(x);
        vi.pb(x);
    }

}
inline int go(int s, int e){
    if( s==N || s>e  ){
        return 0;
    }

    int &best = dp[s][e];
    if( best!=-1 ){
        return best;
    }
    best = (int)1023456789;
    // kono dress na khule
    int var = 1+go( s+1, e );
    best = min( best, var );


    // if dress khule...
    // go through all future match for current dress
    for(int i=s+1;i<N;++i){
        if( vi[s] == vi[i] ){
            int var1 = go(s+1,i-1);
            int var2 = go(i,e);
            best = min( best, var1+var2 );
        }
    }

return best;
}
inline void Proc(){
    SET(dp,-1);
    int var = go(0,N-1);
    printf("Case %d: ",kase);++kase;
    cout<<var<<"\n";
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("in", "rt", stdin);
    //freopen("out","wt",stdout);
#endif
    int cases = 1;
    for ( CI(cases) ; cases; --cases) {
        Read();
        Proc();
    }

    return 0;
}
